package leetcode.code2482;

public class Solution {
	public int[][] onesMinusZeros(int[][] grid) {
		int m = grid.length, n = grid[0].length;
		int[] oneRow = new int[m];
		int[] oneCol = new int[n];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				int cur = grid[i][j];
				if (cur == 1) {
					oneRow[i]++;
					oneCol[j]++;
				}
			}
		}
		int[][] ans = new int[m][n];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				ans[i][j] = oneRow[i] + oneCol[j] - (m - oneRow[i]) - (n - oneCol[j]);
			}
		}
		return ans;
	}
}
